Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-loader

Package Overview
Dependencies
Maintainers
5
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-loader

babel module loader for webpack

  • 8.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19M
increased by3.3%
Maintainers
5
Weekly downloads
 
Created

What is babel-loader?

The babel-loader npm package is a Webpack plugin that integrates Babel with Webpack. Babel is a JavaScript compiler that allows you to use next-generation JavaScript, today. It compiles ES6 and beyond into ES5 code that can run in current browser environments. babel-loader enables Webpack to process and bundle JavaScript files using Babel.

What are babel-loader's main functionalities?

Transpiling ES6+ to ES5

This feature allows developers to write modern JavaScript code without worrying about compatibility issues with older browsers. The code sample shows a Webpack configuration that uses babel-loader to process files ending in .js, excluding node_modules, and transpiles them using the preset '@babel/preset-env'.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  }
};

Using Babel plugins

babel-loader can be configured to use specific Babel plugins to enable experimental features or custom transformations. The code sample demonstrates how to include the '@babel/plugin-proposal-class-properties' plugin to allow the use of class properties syntax in JavaScript.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            plugins: ['@babel/plugin-proposal-class-properties']
          }
        }
      }
    ]
  }
};

Source Maps support

babel-loader supports source maps, which help in debugging transpiled code by mapping the transformed code back to the original source code. The code sample shows how to enable source maps in the babel-loader options.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            sourceMaps: true
          }
        }
      }
    ]
  }
};

Other packages similar to babel-loader

Keywords

FAQs

Package last updated on 16 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc